This page last changed on Apr 28, 2006 by rossmason.

The IMAP transport provider can be used to for receiving messages from IMAP inboxes and connecting to IMAP mailboxes using SSL (IMAPs) using the javax.mail api.

The javadoc for this provider can be found here.

org.mule.providers.email.ImapConnector.

Imap Connector Properties

Property Description Default Required
mailboxFolder The remote mailbox folder to connect to. INBOX Yes
backupFolder This refers to a file system folder to backup consumed mail messages to. This is really only for audit purposes.   No
checkFrequency Determines how often the Pop3 mailbox is polled for new messages. the value is represented in milliseconds. 60000 Yes
authenticator Is used when setting up a Mail session. By default Mule handles authentication by creating a default Authenticator if there are user credentials set on the Pop3 endpoint (see below). Users can customise the authenticator if needed by setting this to their own authenticator implementation. Authenitcators must implement javax.mail.Authenticator   No
deleteReadMessages whether to delete messages once they have been read. Otherwise they are marked as SEEN. The bahaviour of different mail servers differs and on some mail servers setting the SEEN flag seems to have no effect. true No
Server Credentials

The host, port and user credentials as set on the imap:// endpoint. If no port is specifed the default port will be used.

Imaps Connector Properties

The Imaps Connector enables Imap over SSL using the javax.mail APIs. It supports all the properties of the Imap connector and has some additional properties for setting up an SSL connection.

Property Description Default Required
socketFactory The SSL socket factory to use javax.net.ssl.SSLSocketFactory No
socketFactoryFallback Whether to enable fallback false No
trustStore The flie location of a trust store   No
trustStorePassword The password for the trust store   No

When using the Imaps Connector the default port is set to 993.

Imap(s) Endpoints

Imap endpoints describe details about the connecting to a Imap mailbox. Imap URIs use the following syntax -

imap://<user:password>@<imap server>[:port]/<mail folder>[?params]

The format is the same for IMAPs -

imaps://<user:password>@<imap server>[:port]/<mail folder>[?params]
Escape your credentials

Sometimes you'll have illegal (for URI) characters in your login/password. Use the standard escape syntax your browser would use, e.g. the username user@mule would become user%40mule.

For example,

imaps://joe:[email protected]/mail?checkFrequency=30000

This will log into the imap.mycompany.com server with username joe using password 123456 (using default IMAPs port) and open the mail folder. It will check the mailbox for new messages every 30 seconds.

To set additional properties on the endpoint, you can set them as parameters on the URI but we recommend you set them as endpoint properties to make it easier to read and maintain the configuration.

<endpoint address="imaps://username:[email protected]/mail">
    <properties>
        <property name="checkFrequency" value="120000"/>
        <property name="trustStore" value="./trustore"/>
        <property name="trustStorePassword" value="trustNoOne"/>
    </properties>
</endpoint>

Filters

Filters can be set on an endpoint to filter out any unwanted messages. The Mail transport provider has a couple of Email filters that can either be used directly or extended to implement custom filtering rules.

Filter Description
org.mule.providers.email.filters. AbstractMailFilter A base filter implementation that must be extended by any other mail filter.
org.mule.providers.email.filters. MailSubjectRegExFilter Will filter messages based on their subject matching a regex filter.

Configuring Filters

The following demonstrates to only accept messages where the email subject starts with [mule] -

<endpoint address="imaps://username:[email protected]/lists">
    <filter className="org.mule.providers.email.filters.MailSubjectRegExFilter"
        pattern="\\[mule\\](.*)"/>
    <properties>
        <property name="checkFrequency" value="120000"/>
        <property name="trustStore" value="./trustore"/>
        <property name="trustStorePassword" value="trustNoOne"/>
    </properties>
</endpoint>

Transformers

There are a couple of transformers provided with the Email transport that are useful for converting javax.mail.Message to Mule event payloads. These transformers will extract the message body and properties (including headers) and handle attachments too. If you need to customise the behaviour of these transformers it is recommended that you extends the existing transformers rather than re-implement them.

Transformer Description
org.mule.providers.email.transformers. EmailMessageToString Converts a javax.mail.Message to String message payload. This transformer doesn't support attachements and is deprecated in favour of the MimeMessageToObject transformer
Converting a MimeMessage to a UMOMessage The MessageAdapter for Pop3 is responsible for decomposing a MimeMessage to a UMOMessage. the first body part is used as the payload and all subsequent parts are added as attachments. The mimEMessage headers are added to the UMOMessage properties.
Document generated by Confluence on Nov 27, 2006 10:27